package com.example.android.xxm;

import android.app.Activity;
import android.app.Application;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by Android on 2017/3/9.
 */

public class exit extends Application {
    private List<Activity> activityList = new LinkedList<Activity>();
    private static exit instance;
    public exit(){
    }
    public static exit getInstance(){
        if(instance == null){
            instance = new exit();
        }
        return instance;
    }
    public void addActivity(Activity activity){
        activityList.add(activity);
    }
    //遍历所有Activity并finish()
    public void exit(){
        for(Activity activity:activityList){
            activity.finish();
        }
        System.exit(0);
    }
}
